<!-- 模块说明 -->
<template>
  <div>
    <el-table border :data="answerList" style="width: 100%">
      <el-table-column label="ID" width="180">
        <template #default="{ row }">
          <span>{{ row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="试卷名称">
        <template #default="{ row }">
          <span>{{ row.name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="答题人">
        <template #default="{  }">
          <span>student</span>
        </template>
      </el-table-column>
      <el-table-column label="分数">
        <template #default="{ row }">
          <span>{{ row.score }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="题目对错">
        <template #default="{ row }">
          <span>0/{{ row.titleItems.length }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="限时">
        <template #default="{ row }">
          <span>{{ row.suggestTime }}分</span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template #default="{ row }">
          <el-button @click="toCorrect(row)">批改</el-button>
          <el-button @click="toPDF(row)">打印</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { getPaperList } from "../../api/index";
import { useRouter } from "vue-router";
import {useStore} from 'vuex'
const store = useStore()
const router = useRouter();
// const route = useRoute();
const answerList = ref([]);
const getAnswerList = async () => {
  let res = await getPaperList();
  console.log(res);
  answerList.value = res.data;
};
const toPDF = (row: any) => {
  console.log(row);
  store.commit('pdf/SET_PDF',row)
  router.push("/answer/pdf");
};
const toCorrect = (row: any) => {
  console.log(row);
  store.commit('pdf/SET_PDF',row)
  store.commit('pdf/DEL_SUM')
  store.commit('pdf/DEL_PRICE')
  router.push("/answer/completeList");
};
onMounted(() => {
  getAnswerList();
});
</script>
<style lang="scss" scoped></style>
